using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SajtLibrary.SajtClasses;

public partial class Prijav : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        SajtLibrary.SajtClasses.User user = new User(Login1.UserName, Login1.Password);
        bool authenticated = user.authenticate();
        if (authenticated)
        {
            SessionUtils.storeUserInformation(user);
            e.Authenticated = true;
            
            if (user.IsClient)
            {
                Login1.DestinationPageUrl = "~/Client/SearchProducts.aspx";
            }
            else if (user.IsAdministrator)
            {
                Login1.DestinationPageUrl = "~/Admin/CreateProduct.aspx";
            }
            //Login1.DestinationPageUrl = "http://www.google.com";
        }
        else
        {
            e.Authenticated = false;
        }
    }

    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
        // Response.Redirect("~/Studenti.aspx");
    }
}
